<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>登录</title>
    <link rel="stylesheet" href="/component/pear/css/pear.css"/>
    <link rel="stylesheet" href="/admin/css/other/login.css"/>
</head>
<body background="/admin/images/background.svg" style="background-size: cover;">
<form class="layui-form" action="javascript:void(0);">
    <div class="layui-form-item">
        <img class="logo" src="/admin/images/logo.png"/>
        <div class="title">ZhiNan Space</div>
        <div class="desc">
            欢迎登录之南后台管理系统！
        </div>
    </div>
    <div class="layui-form-item">
        <input name="userNum" placeholder="请输入账号" lay-verify="required" hover class="layui-input"/>
    </div>
    <div class="layui-form-item">
        <input name="userPwd" placeholder="请输入密码" lay-verify="required" hover class="layui-input"/>
    </div>
    <div class="layui-form-item">
        <input placeholder="验证码 : " name="validateCode" hover lay-verify="required"
               class="code layui-input layui-input-inline"/>
        <img src="kaptcha/kaptchaImage" class="codeImage"/>
    </div>
    <div class="layui-form-item">
        <input type="checkbox" name="rememberMe" title="记住我" lay-skin="primary" checked>
    </div>
    <div class="layui-form-item">
        <button type="button" id="submit" class="pear-btn pear-btn-success login" lay-submit lay-filter="login"
                style="margin-bottom: 14px">
            登陆
        </button>
        <button type="button" id="reg" class="pear-btn-success">注册</button>
    </div>
</form>
<script src="/component/layui/layui.js"></script>
<script src="/component/pear/pear.js"></script>
<script src="/component/common/common.js"></script>
<script src="/component/common/jquery-2.1.4.min.js"></script>
<script>
    $(function () {

        document.onkeydown = function () {
            if (event.keyCode === 13) {
                $('#submit').trigger('click')
                return false;
            }
        }

        layui.use(['form', 'button', 'popup', 'layer'], function () {
            let form = layui.form;
            let button = layui.button;
            let popup = layui.popup;
            let layer = layui.layer;


            //登录
            form.on('submit(login)', function (data) {
                button.load({
                    elem: '.login',
                    time: 1500,
                    done: function () {
                        defaultPost("/sysuser/login", data.field, function (res) {

                            if (res.flag) {
                                location.href = "index.html";
                            } else {
                                popup.failure(res.msg)

                            }
                        }, function (err) {
                            layer.msg("验证码错误", {icon: 2, time: 2000}, function () {
                                location.reload();
                            })
                        })
                    }
                })
                return false;
            });

            //注册
            $("#reg").on('click', function () {
                parent.layer.close(parent.layer.getFrameIndex(window.name))
                parent.layer.open({
                    type: 2,
                    title: "注册",
                    content: 'reg.html',
                    area: ['500px', '550px']
                })
            })
        })
    })
</script>
</body>
</html>
